
use main_analysis_data.dta, clear                                                                                     


* Table 4: Summary statistics
eststo clear
estpost ttest cos_combo cos_multicult pop_vote_share ///
              gdp_pc inflation unemp institutions, by(pop_temp)
esttab, cells("mu_1(fmt(2)) mu_2(fmt(2)) p(fmt(3))") compress nonumbers noobs ///
 title(Table 4: Summary statistics (pre-matching)) varwidth(52) ///
 refcat(cos_combo "Difference in positions (cosine distance)" pop_vote_share "Covariates") ///
 coeflabels(cos_combo "- equality and welfare" ///
 cos_multicult "- multiculturalism" ///
 pop_vote_share "Aggregate populist vote share (%)" ///
 gdp_pc "GDP per capita (USD)" ///
 inflation "inflation rate (%)" ///
  unemp "Unemployment rate (%)" ///
  institutions "Quality of institutions (index)")




* Winsorizing
winsor2 pop_vote_share inflation gdp_pc unemp institutions , cuts(10 90) replace by(year)

* Matching
psmatch2 pop_temp gdp_pc institutions inflation unemp pop_vote_share, kernel



* Table 4: Mean differences between treated and untreated observations after matching
foreach var of varlist pop_vote_share gdp_pc inflation unemp institutions {
              reg `var' pop_temp [aweight=_weight]
              }
			  
pstest pop_vote_share gdp_pc inflation unemp institutions, mweight(_weight)
			  
			  
			  		  
* Figure A1: Distribution of propensity scores
* A: Before matching
twoway (kdensity _pscore if _treated==1) (kdensity _pscore if _treated==0, ///
lpattern(dash)), legend( label( 1 "treated") label( 2 "control" ) ) ///
xtitle(" " "Propensity scores") ytitle("Kernel density") ylabel(0(10)40, gmin gmax angle(0)) ///
scheme(s2mono) graphregion(fcolor(white)) scale(1.3) legend(pos(3) rows(2) size(small))

* B: After matching
twoway (kdensity _pscore if _treated==1 [aweight=_weight]) ///
(kdensity _pscore if _treated==0 [aweight=_weight], ///
lpattern(dash)), legend( label( 1 "treated") label( 2 "control" ) ) ///
xtitle(" " "Propensity scores") ytitle("Kernel density") ylabel(0(10)40, gmin gmax angle(0)) ///
scheme(s2mono) graphregion(fcolor(white)) scale(1.3) legend(pos(3) rows(2) size(small))




*******************
*Baseline Results *
*******************

* Table 6: Impact of populist leadership on party positions
use main_analysis_data.dta , clear

winsor2 pop_vote_share inflation gdp_pc unemp institutions , cuts(10 90) replace by(year)
psmatch2 pop_temp gdp_pc institutions inflation unemp pop_vote_share, kernel

global notes_obs = "Based on matched data on 2,083 party pairs."
global notes_dep_diff = "The dependent variables capture the degree of differentiation between pairs of parties in the policy categories stated in the column headers, measured as the average cosine distance between parties' manifesto statements pertaining to the categories."
global notes_fe = "All models include country fixed effects, year fixed effects, and binary variable indicating party-pairs with a state leader (output omitted)."
global notes_se = "Standard errors (in parentheses) are clustered by election."

eststo clear
quietly eststo: reghdfe cos_combo i.pop  leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
                estadd ysumm
quietly eststo: reghdfe cos_multicult i.pop leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
                estadd ysumm
esttab, label star(* 0.10 ** 0.05 *** 0.01) se compress nonotes varwidth(30) noobs ///
 cells(b(fmt(3) star) se(par fmt(3))) nodepvars modelwidth(22) drop(1.pop leader)  ///
 scalars("ymean Mean of dep. variable" "ysd SD of dep. variable" ///
 "r2_a Adj. R2") sfmt(3 3 3) ///
 title(Table 6: Impact of populist leadership on party positions) ///
 mtitles("Equality and welfare" "Multiculturalism") ///
 addnotes("Notes: $notes_obs $notes_dep_diff $notes_fe $notes_se" ///
 "* p<0.10, ** p<0.05, *** p<0.01")
 
 
 

 
********************
*Robustness checks *
********************
		

* Table A4: Impact of populist leadership on party positions (traditional position measures)
use "traditional_data_extended.dta", clear

quietly winsor2 pop_vote_share inflation gdp_pc unemp institutions if original == 1, cuts(10 90) by(year)
psmatch2 pop_temp gdp_pc_w institutions_w inflation_w unemp_w pop_vote_share_w if original == 1, kernel
rename _weight weight_original

quietly winsor2 pop_vote_share inflation gdp_pc unemp institutions if original == 0, cuts(10 90) replace by(year)
psmatch2 pop_temp gdp_pc institutions inflation unemp pop_vote_share if original == 0, kernel

global notes_est = "Estimates based on matched party-pair data. The baseline sample includes observations where content-analytical data are available, whereas the extended sample includes all observations where only data for the traditional position measures are available."
global notes_dep_diff_trad = "The dependent variables capture the degree of differentiation between pairs of parties in the policy categories stated in the column headers, measured as the absolute difference of percentages of relevant statements in their manifestos."
global notes_fe = "All models include country fixed effects, year fixed effects, and binary variable indicating party-pairs with a state leader (output omitted)."
global notes_se = "Standard errors (in parentheses) are clustered by election."

eststo clear
quietly eststo: reghdfe diff_combo i.pop leader [aweight=weight_original], absorb(country_id year) cluster(election_id) nocons
				estadd ysumm
quietly eststo: reghdfe diff_multicult i.pop leader [aweight=weight_original], absorb(country_id year) cluster(election_id) nocons
				estadd ysumm
quietly eststo: reghdfe diff_combo i.pop leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
				estadd ysumm
quietly eststo: reghdfe diff_multicult i.pop leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
				estadd ysumm
esttab, label star(* 0.10 ** 0.05 *** 0.01) se compress nonotes varwidth(30) noobs ///
 cells(b(fmt(3) star) se(par fmt(3))) nodepvars modelwidth(16) drop(1.pop leader)  ///
 scalars("ymean Mean of dep. variable" "ysd SD of dep. variable" "r2_a Adj. R2" "N_full Observations") sfmt(3 3 3 0) ///
 title(Table A4: Impact of populist leadership on party positions (traditional position measures)) ///
 mgroups("Baseline sample" "Extended sample", pattern(1 0 1 0)) ///
 mtitles("Equality and welfare" "Multiculturalism" "Equality and welfare" "Multiculturalism" ) ///
 addnotes("$notes_est $notes_dep_diff_trad $notes_fe $notes_se" ///
 "* p<0.10, ** p<0.05, *** p<0.01")	

	
	
	
* Table A5: Impact of populist leadership on party positions (recoding positions measures)
use main_analysis_data.dta , clear

winsor2 pop_vote_share inflation gdp_pc unemp institutions , cuts(10 90) replace by(year)
psmatch2 pop_temp gdp_pc institutions inflation unemp pop_vote_share, kernel

gen cos_combo_v2 = cos_combo
quietly sum cos_combo_v2 if cos_combo_v2 != 0 & cos_combo_v2 != 1, d
gen p10 = r(p10)
gen p90 = r(p90)
replace cos_combo_v2 = p10 if cos_combo_v2 < p10
replace cos_combo_v2 = p90 if cos_combo_v2 > p90
drop p10 p90
gen cos_combo_v3 = cos_combo
quietly sum cos_combo_v3 if cos_combo_v3 != 0 & cos_combo_v3 != 1, d
gen p1 = r(p1)
gen p99 = r(p99)
replace cos_combo_v3 = p1 if cos_combo_v3 < p1
replace cos_combo_v3 = p99 if cos_combo_v3 > p99
drop p1 p99

gen cos_multicult_v2 = cos_multicult
quietly sum cos_multicult_v2 if cos_multicult_v2 != 0 & cos_multicult_v2 != 1, d
gen p10 = r(p10)
gen p90 = r(p90)
replace cos_multicult_v2 = p10 if cos_multicult_v2 < p10
replace cos_multicult_v2 = p90 if cos_multicult_v2 > p90
drop p10 p90
gen cos_multicult_v3 = cos_multicult
quietly sum cos_multicult_v3 if cos_multicult_v3 != 0 & cos_multicult_v3 != 1, d
gen p1 = r(p1)
gen p99 = r(p99)
replace cos_multicult_v3 = p1 if cos_multicult_v3 < p1
replace cos_multicult_v3 = p99 if cos_multicult_v3 > p99
drop p1 p99
 
global notes_obs = "Based on matched data on 2,083 party pairs."
global notes_dep_diff_rec = "The dependent variables capture the degree of differentiation between pairs of parties in the policy categories stated in the column headers, measured as the average cosine distance between parties' manifesto statements pertaining to the categories (winsorized at the percentiles specified in the table header)."
global notes_fe = "All models include country fixed effects, year fixed effects, and binary variable indicating party-pairs with a state leader (output omitted)."
global notes_se = "Standard errors (in parentheses) are clustered by election."

eststo clear
quietly eststo: reghdfe cos_combo_v3 i.pop  leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
                estadd ysumm
quietly eststo: reghdfe cos_multicult_v3 i.pop leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
                estadd ysumm		
quietly eststo: reghdfe cos_combo_v2 i.pop  leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
                estadd ysumm
quietly eststo: reghdfe cos_multicult_v2 i.pop leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
                estadd ysumm						
esttab, label star(* 0.10 ** 0.05 *** 0.01) se compress nonotes varwidth(30) noobs ///
 cells(b(fmt(3) star) se(par fmt(3))) nodepvars modelwidth(22) drop(1.pop leader)  ///
 scalars("ymean Mean of dep. variable" "ysd SD of dep. variable" ///
 "r2_a Adj. R2") sfmt(3 3 3) ///
 title(Table A5: Impact of populist leadership on party positions (recoding positions measures)) ///
 mgroups("Winsorized at p1 and p99" "Winsorized at p10 and p90", pattern(1 0 1 0)) ///
 mtitles("Equality and welfare" "Multiculturalism" "Equality and welfare" "Multiculturalism") ///
 addnotes("Notes: $notes_obs $notes_dep_diff_rec $notes_fe $notes_se" ///
 "* p<0.10, ** p<0.05, *** p<0.01") 
 
 	
	

			
		
* Table A7: Impact of populist leadership on party positions (alternative matching procedures)
use main_analysis_data.dta , clear

winsor2 pop_vote_share inflation gdp_pc unemp institutions , cuts(10 90) replace by(year)
psmatch2 pop_temp gdp_pc institutions inflation unemp pop_vote_share, kernel

quietly eststo: reghdfe cos_multicult i.pop leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
gen flag1= e(sample)

kmatch ipw pop_temp gdp_pc institutions inflation unemp pop_vote_share (cos_combo), pscmd(probit) att wgenerate(w)
ebalance pop_temp pop_vote_share inflation gdp_pc unemp institutions, tar(1)
global notes_obs = "Based on matched data on 2,083 party pairs."
global notes_dep_diff = "The dependent variables capture the degree of differentiation between pairs of parties in the policy categories stated in the column headers, measured as the average cosine distance between parties' manifesto statements pertaining to the categories."
global notes_fe = "All models include country fixed effects, year fixed effects, and binary variable indicating party-pairs with a state leader (output omitted)."
global notes_se = "Standard errors (in parentheses) are clustered by election."

eststo clear

quietly eststo: reghdfe cos_combo i.pop  leader [aweight=w] if flag1 == 1, absorb(country_id year) cluster(election_id) nocons
                estadd ysumm
quietly eststo: reghdfe cos_multicult i.pop leader [aweight=w] if flag1 == 1, absorb(country_id year) cluster(election_id) nocons
                estadd ysumm
				
quietly eststo: reghdfe cos_combo i.pop  leader [aweight=_webal] if flag1 == 1, absorb(country_id year) cluster(election_id) nocons
                estadd ysumm
quietly eststo: reghdfe cos_multicult i.pop leader [aweight=_webal] if flag1 == 1, absorb(country_id year) cluster(election_id) nocons
                estadd ysumm				
esttab, label star(* 0.10 ** 0.05 *** 0.01) se compress nonotes varwidth(40) noobs ///
 cells(b(fmt(3) star) se(par fmt(3))) nodepvars modelwidth(20) drop(1.pop leader)  ///
 scalars("ymean Mean of dep. variable" "ysd SD of dep. variable" ///
 "r2_a Adj. R2") sfmt(3 3 3) ///
 title(Table A7: Impact of populist leadership on party positions (alternative matching procedures)) ///
 mgroups("Inverse probability weighting" "Entropy balancing", pattern(1 0 1 0)) ///
 mtitles("Equality and welfare" "Multiculturalism" "Equality and welfare" "Multiculturalism" ) ///
 addnotes("Notes: $notes_obs $notes_dep_diff $notes_fe $notes_se" ///
 "* p<0.10, ** p<0.05, *** p<0.01")
 
 
 
 


* Table A8: Impact of populist leadership on party positions (no winsorizing)
use main_analysis_data.dta , clear

psmatch2 pop_temp gdp_pc institutions inflation unemp pop_vote_share, kernel 

global notes_obs_no_win = "Based on matched data on 2,110 party pairs."
global notes_dep_diff = "The dependent variables capture the degree of differentiation between pairs of parties in the policy categories stated in the column headers, measured as the average cosine distance between parties' manifesto statements pertaining to the categories."
global notes_fe = "All models include country fixed effects, year fixed effects, and binary variable indicating party-pairs with a state leader (output omitted)."
global notes_se = "Standard errors (in parentheses) are clustered by election."

eststo clear
quietly eststo: reghdfe cos_combo i.pop  leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
                estadd ysumm
quietly eststo: reghdfe cos_multicult i.pop leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
                estadd ysumm
esttab, label star(* 0.10 ** 0.05 *** 0.01) se compress nonotes varwidth(30) noobs ///
 cells(b(fmt(3) star) se(par fmt(3))) nodepvars modelwidth(22) drop(1.pop leader)  ///
 scalars("ymean Mean of dep. variable" "ysd SD of dep. variable" ///
 "r2_a Adj. R2") sfmt(3 3 3) ///
 title(Table A8: Impact of populist leadership on party positions (no winsorizing)) ///
 mtitles("Equality and welfare" "Multiculturalism") ///
 addnotes("Notes: $notes_obs_no_win $notes_dep_diff $notes_fe $notes_se" ///
 "* p<0.10, ** p<0.05, *** p<0.01")
 
  
 
 
* Table A9: Impact of populist leadership on party positions (alternative standard errors)
use main_analysis_data.dta , clear

egen pair_id = group(party1 party2)

quietly winsor2 pop_vote_share inflation gdp_pc unemp institutions, cuts(10 90) replace by(year) 
psmatch2 pop_temp gdp_pc institutions inflation unemp pop_vote_share, kernel

global notes_obs = "Based on matched data on 2,083 party pairs."
global notes_dep_diff = "The dependent variables capture the degree of differentiation between pairs of parties in the policy categories stated in the column headers, measured as the average cosine distance between parties' manifesto statements pertaining to the categories."
global notes_fe = "All models include country fixed effects, year fixed effects, and binary variable indicating party-pairs with a state leader (output omitted)."
global notes_se_alt = "Standard errors are in parentheses."

eststo clear

quietly eststo: reghdfe cos_combo i.pop  leader [aweight=_weight], absorb(country_id year) cluster(country_id) nocons
                estadd ysumm
quietly eststo: reghdfe cos_multicult i.pop leader [aweight=_weight], absorb(country_id year) cluster(country_id) nocons
                estadd ysumm
quietly eststo: reghdfe cos_combo i.pop  leader [aweight=_weight], absorb(country_id year) cluster(pair_id) nocons
                estadd ysumm
quietly eststo: reghdfe cos_multicult i.pop leader [aweight=_weight], absorb(country_id year) cluster(pair_id) nocons
                estadd ysumm			
quietly eststo: reghdfe cos_combo i.pop  leader [aweight=_weight], absorb(country_id year) vce(robust) nocons
                estadd ysumm
quietly eststo: reghdfe cos_multicult i.pop leader [aweight=_weight], absorb(country_id year) vce(robust) nocons
                estadd ysumm			
esttab, label star(* 0.10 ** 0.05 *** 0.01) se compress nonotes varwidth(30) noobs ///
 cells(b(fmt(3) star) se(par fmt(3))) nodepvars modelwidth(14) drop(1.pop leader)  ///
 scalars("ymean Mean of dep. variable" "ysd SD of dep. variable" ///
 "r2_a Adj. R2") sfmt(3 3 3) ///
 title(Table A9: Impact of populist leadership on party positions (standard errors clustered by country)) ///
 mgroups("Clustered by country" "Clustered by party pair" "Heteroscedasticity-robust", pattern(1 0 1 0 1 0)) ///
 mtitles("Equality and welfare" "Multiculturalism" "Equality and welfare" "Multiculturalism" "Equality and welfare" "Multiculturalism" ) ///
 addnotes("Notes: $notes_obs $notes_dep_diff $notes_fe $notes_se_alt" ///
 "* p<0.10, ** p<0.05, *** p<0.01")

 
 
 


* Table A10: Impact of populist leadership on party positions (additional matching variables)
use main_analysis_data.dta , clear

quietly winsor2 pop_vote_share inflation gdp_pc unemp institutions, cuts(10 90) replace by(year)

psmatch2 pop_temp gdp_pc institutions inflation unemp pop_vote_share emerging, kernel
rename _weight weight_a_vs_e

psmatch2 pop_temp gdp_pc institutions inflation unemp pop_vote_share presidential, kernel 
 
global notes_obs = "Based on matched data on 2,083 party pairs."
global notes_dep_diff = "The dependent variables capture the degree of differentiation between pairs of parties in the policy categories stated in the column headers, measured as the average cosine distance between parties' manifesto statements pertaining to the categories."
global notes_fe = "All models include country fixed effects, year fixed effects, and binary variable indicating party-pairs with a state leader (output omitted)."
global notes_se = "Standard errors (in parentheses) are clustered by election."

eststo clear

quietly eststo: reghdfe cos_combo i.pop  leader [aweight=weight_a_vs_e], absorb(country_id year) cluster(election_id) nocons
                estadd ysumm
quietly eststo: reghdfe cos_multicult i.pop leader [aweight=weight_a_vs_e], absorb(country_id year) cluster(election_id) nocons
                estadd ysumm

quietly eststo: reghdfe cos_combo i.pop  leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
                estadd ysumm
quietly eststo: reghdfe cos_multicult i.pop leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
                estadd ysumm			
				
esttab, label star(* 0.10 ** 0.05 *** 0.01) se compress nonotes varwidth(30) noobs ///
 cells(b(fmt(3) star) se(par fmt(3))) nodepvars modelwidth(22) drop(1.pop leader)  ///
 scalars("ymean Mean of dep. variable" "ysd SD of dep. variable" ///
 "r2_a Adj. R2") sfmt(3 3 3) ///
 title(Table A10: Impact of populist leadership on party positions (additional matching variables)) ///
 mgroups("Adding development status (advanced vs. emerging)" "Adding political system (parliamentary vs. presidential)", pattern(1 0 1 0)) ///
 mtitles("Equality and welfare" "Multiculturalism" "Equality and welfare" "Multiculturalism" ) ///
 addnotes("Notes: $notes_obs $notes_dep_diff $notes_fe $notes_se" ///
 "* p<0.10, ** p<0.05, *** p<0.01")
 
 
 
* Table A11: Impact of populist leadership on party positions (alternative definition of populist state leaders)
use main_analysis_data.dta , clear

winsor2 pop_vote_share_v2 inflation_v2 gdp_pc_v2 unemp_v2 institutions_v2, cuts(10 90) replace by(year)
psmatch2 pop_temp_v2 gdp_pc_v2 institutions_v2 inflation_v2 unemp_v2 pop_vote_share_v2, kernel

global notes_obs_alt = "Based on matched data on 2,126 party pairs. The regressions use data where we classify four borderline cases of populist incumbent state leaders as non-populist (Boyko Borisov, Robert Fico, Cristina Fernández de Kirchner, and Aléxis Tsípras)."
global notes_dep_diff = "The dependent variables capture the degree of differentiation between pairs of parties in the policy categories stated in the column headers, measured as the average cosine distance between parties' manifesto statements pertaining to the categories."
global notes_fe = "All models include country fixed effects, year fixed effects, and binary variable indicating party-pairs with a state leader (output omitted)."
global notes_se = "Standard errors (in parentheses) are clustered by election."

eststo clear
quietly eststo: reghdfe cos_combo i.pop_v2 leader_v2 [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
                estadd ysumm
quietly eststo: reghdfe cos_multicult i.pop_v2 leader_v2 [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
                estadd ysumm
esttab, label star(* 0.10 ** 0.05 *** 0.01) se compress nonotes varwidth(30) noobs ///
 cells(b(fmt(3) star) se(par fmt(3))) nodepvars modelwidth(22) drop(1.pop_v2 leader_v2)  ///
 scalars("ymean Mean of dep. variable" "ysd SD of dep. variable" ///
 "r2_a Adj. R2") sfmt(3 3 3) ///
 title(Table A11: Impact of populist leadership on party positions (alternative definition of populist state leaders)) ///
 mtitles("Equality and welfare" "Multiculturalism") ///
 addnotes("Notes: $notes_obs_alt $notes_dep_diff $notes_fe $notes_se" ///
 "* p<0.10, ** p<0.05, *** p<0.01")
 
 


* Table A12: Impact of populist leadership on party positions (election-level regressions)
use main_analysis_data.dta , clear

quietly winsor2 pop_vote_share inflation gdp_pc unemp institutions, cuts(10 90) replace by(year) 
psmatch2 pop_temp gdp_pc institutions inflation unemp pop_vote_share, kernel 

drop if missing(_weight)

collapse (mean) cos_multicult cos_combo pop _weight ///
 (first) country_id year (count) n=_weight, by(election_id)

replace _weight=_weight*n

global notes_obs_mean = "Based on matched data collapsed by 215 elections."
global notes_dep_diff = "The dependent variables capture the degree of differentiation between pairs of parties in the policy categories stated in the column headers, measured as the average cosine distance between parties' manifesto statements pertaining to the categories."
global notes_fe_mean = "All models include country fixed effects and year fixed effects."
global notes_se_mean = "Standard errors (in parentheses) are clustered by country."
 
eststo clear
quietly eststo: reghdfe cos_combo i.pop [aweight=_weight], absorb(country_id year) cluster(country_id) nocons
                estadd ysumm
quietly eststo: reghdfe cos_multicult i.pop [aweight=_weight], absorb(country_id year) cluster(country_id) nocons
                estadd ysumm
esttab, label star(* 0.10 ** 0.05 *** 0.01) se compress nonotes varwidth(30) noobs ///
 cells(b(fmt(3) star) se(par fmt(3))) nodepvars modelwidth(22) drop(1.pop)  ///
 scalars("ymean Mean of dep. variable" "ysd SD of dep. variable" ///
 "r2_a Adj. R2") sfmt(3 3 3) ///
 coeflabels(2.pop "Left populist" 3.pop "Right populist") ///
 title(Table A12: Impact of populist leadership on party positions (election-level regressions)) ///
 mtitles("Equality and welfare" "Multiculturalism") ///
 addnotes("Notes: $notes_obs_mean $notes_dep_diff $notes_fe_mean $notes_se_mean" ///
 "* p<0.10, ** p<0.05, *** p<0.01")
 


 


 
 
*****************************
* Distribution of positions *
*****************************

* "hist" doesn't work with analytical weights; transform weight into integer frequency weights
use main_analysis_data.dta , clear
quietly winsor2 pop_vote_share inflation gdp_pc unemp institutions, cuts(10 90) replace by(year)
psmatch2 pop_temp gdp_pc institutions inflation unemp pop_vote_share, kernel 

gen fweight = round(_weight*10000)

quietly reg cos_multicult i.country_id i.year leader  [aweight = _weight]
predict cos_multicult_res, res
quietly winsor2 cos_multicult_res, cuts(1 99) replace trim

* Figure 2: Distribution of party positions on multiculturalism
* A: Left-wing populists
twoway (hist cos_multicult_res if pop == 1 [fweight = fweight], width(0.17) frac col(gs10%50) lsty(none))  ///
       (kdensity cos_multicult_res if pop == 1 [fweight = fweight], kernel(epan2) bwidth(0.38) area(0.39) boundary lwidth(0.5) lpattern(solid) lcolor(gs10%50)) ///
       (hist cos_multicult_res if pop == 2, width(0.17) frac col(black%50) lsty(none)) ///
	   (kdensity cos_multicult_res if pop == 2, kernel(epan2) bwidth(0.38) area(0.5) boundary lwidth(0.39) lpattern(solid) lcolor(black%50)), ///
        scheme(s2mono) graphregion(color(white)) scale(1.4) aspect(0.7) plotregion(margin(zero)) ///
		ylabel(, gmin gmax angle(0)) xlabel() ///
		ytitle("Share of party pairs") xtitle("Residualized distance between positions") ///
		legend(order(3 "Incumbent left-wing populist" 1 "Matched control non-populist observations") symx(#1) si(small) rows(2)) 

* B: Right-wing populists
twoway (hist cos_multicult_res if pop == 1 [fweight = fweight], width(0.17) frac col(gs10%50) lsty(none)) ///
       (kdensity cos_multicult_res if pop == 1 [fweight = fweight], kernel(epan2) bwidth(0.38) area(0.39) boundary lwidth(0.5) lpattern(solid) lcolor(gs10%50))  ///
       (hist cos_multicult_res if pop == 3, width(0.17) frac col(black%50) lsty(none)) ///
	   (kdensity cos_multicult_res if pop == 3, kernel(epan2) bwidth(0.38) area(0.39) boundary lwidth(0.5) lpattern(solid) lcolor(black%50)), ///
        scheme(s2mono) graphregion(color(white)) scale(1.4) aspect(0.7) plotregion(margin(zero)) ///
		ylabel(, gmin gmax angle(0)) xlabel() ///
		ytitle("Share of party pairs") xtitle("Residualized distance between positions") ///
		legend(order(3 "Incumbent right-wing populist" 1 "Matched control non-populist observations") symx(#1) si(small) rows(2)) 






*******************************************
* Differential effects by type of country *
*******************************************
use main_analysis_data.dta , clear
quietly winsor2 pop_vote_share inflation gdp_pc unemp institutions, cuts(10 90) replace by(year)
psmatch2 pop_temp gdp_pc institutions inflation unemp pop_vote_share, kernel 

gen pop_right_advanced = 0
gen pop_right_emerging = 0
gen pop_left_advanced = 0
gen pop_left_emerging = 0
replace pop_right_advanced = 1 if pop == 3 & emerging == 0
replace pop_right_emerging = 1 if pop == 3 & emerging == 1
replace pop_left_advanced = 1 if pop == 2 & emerging == 0
replace pop_left_emerging = 1 if pop == 2 & emerging == 1

* Figure 3: Differential effects of populist state leaders, by countries' development status
* A: Equality and welfare
reghdfe cos_combo pop_left_advanced pop_left_emerging pop_right_advanced pop_right_emerging ///
 leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
est sto w 
coefplot w, keep(pop*) scheme(s2mono) msymbol(O) msize(medsmall) ciopt(lcolor(gs8)) ///
 levels(95) mcolor(black) legend(off) graphregion(color(white)) ///
 xline(0, lpattern(dash)) ylabel(, angle(0) gmin gmax) ///
 xtitle(" " "Coefficient value") scale(1.5) ///
 ylabel(1 "Left populist x advanced" 2 "Left populist x emerging" 3 ///
 "Right populist x advanced" 4 "Right populist x emerging")
* B: Multiculturalism
reghdfe cos_multicult pop_left_advanced pop_left_emerging pop_right_advanced pop_right_emerging ///
 leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
est sto w
coefplot w, keep(pop*) scheme(s2mono) msymbol(O) msize(medsmall) ciopt(lcolor(gs8)) ///
 levels(95) mcolor(black) legend(off) graphregion(color(white)) ///
 xline(0, lpattern(dash)) ylabel(, angle(0) gmin gmax) ///
 xtitle(" " "Coefficient value") scale(1.5) ///
 ylabel(1 "Left populist x advanced" 2 "Left populist x emerging" 3 ///
 "Right populist x advanced" 4 "Right populist x emerging")



 
 
 
******************************************
* Differential effects by type of system *
******************************************
use main_analysis_data.dta , clear
quietly winsor2 pop_vote_share inflation gdp_pc unemp institutions, cuts(10 90) replace by(year)
psmatch2 pop_temp gdp_pc institutions inflation unemp pop_vote_share, kernel 

gen pop_right_parl = 0
gen pop_right_pres = 0
gen pop_left_parl = 0
gen pop_left_pres = 0
replace pop_right_parl = 1 if pop == 3 & presidential == 0
replace pop_right_pres = 1 if pop == 3 & presidential == 1
replace pop_left_parl = 1 if pop == 2 & presidential == 0
replace pop_left_pres = 1 if pop == 2 & presidential == 1

* Figure 4: Differential effects of populist state leaders, by countries' political system
* A: Equality and welfare
reghdfe cos_combo pop_left_parl pop_left_pres pop_right_parl pop_right_pres ///
 leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
est sto w
coefplot w, keep(pop*) scheme(s2mono) msymbol(O) msize(medsmall) ciopt(lcolor(gs8)) ///
 levels(95) mcolor(black) legend(off) graphregion(color(white)) ///
 xline(0, lpattern(dash)) ylabel(, angle(0) gmin gmax) ///
 xtitle(" " "Coefficient value") scale(1.5) ///
 ylabel(1 "Left populist x parliamentary" 2 "Left populist x presidential" 3 ///
 "Right populist x parliamentary" 4 "Right populist x presidential")
* B: Multiculturalism
reghdfe cos_multicult pop_left_parl pop_left_pres pop_right_parl pop_right_pres ///
 leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons 
est sto w 
coefplot w, keep(pop*) scheme(s2mono) msymbol(O) msize(medsmall) ciopt(lcolor(gs8)) ///
 levels(95) mcolor(black) legend(off) graphregion(color(white)) ///
 xline(0, lpattern(dash)) ylabel(, angle(0) gmin gmax) ///
 xtitle(" " "Coefficient value") scale(1.5) ///
 ylabel(1 "Left populist x parliamentary" 2 "Left populist x presidential" 3 ///
 "Right populist x parliamentary" 4 "Right populist x presidential")
 
 
 
 



********************
* Placebo exercise *
********************
 
 
* Figure A2: Placebo estimates

* A: Equality and welfare (semantic position measure)
use main_analysis_data.dta , clear

quietly winsor2 pop_vote_share inflation gdp_pc unemp institutions, cuts(10 90) replace by(year)

set seed 12345  // Setting seed for reproducibility

forval iter = 1/1000 {
    gen fake`iter' = runiform() < .0475
}

matrix rf_matrix = J(1000, 1, .)
matrix rf_matrix_ci_lower = J(1000, 1, .)
matrix rf_matrix_ci_upper = J(1000, 1, .)

forval i = 1/1000 {
    local var_name "fake`i'"
    quietly psmatch2 `var_name' gdp_pc institutions inflation unemp pop_vote_share, kernel
    quietly reghdfe cos_combo `var_name' leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
    matrix rf_matrix[`i', 1] = _b[`var_name']
	matrix rf_matrix_ci_lower[`i', 1] = _b[`var_name'] - 1.96 * _se[`var_name']
	matrix rf_matrix_ci_upper[`i', 1] = _b[`var_name'] + 1.96 * _se[`var_name']
}

svmat double rf_matrix
svmat double rf_matrix_ci_lower
svmat double rf_matrix_ci_upper

twoway (kdensity rf_matrix1, lcolor(gs8)), ///
	   scheme(s2mono) graphregion(color(white)) scale(1.8) ///
       xline(0, lpattern(dash) lcolor(gs8)) xlabel() ylabel(, angle(0) nogrid) ///
	   xtitle(" " "Coefficent value") ytitle("Density" " ") ///
	   legend(off)   
	   

* B: Multiculturalism
use main_analysis_data.dta , clear

quietly winsor2 pop_vote_share inflation gdp_pc unemp institutions, cuts(10 90) replace by(year)

set seed 12345  // Setting seed for reproducibility

forval iter = 1/1000 {
    gen fake`iter' = runiform() < .0475
}

matrix rf_matrix = J(1000, 1, .)
matrix rf_matrix_ci_lower = J(1000, 1, .)
matrix rf_matrix_ci_upper = J(1000, 1, .)

forval i = 1/1000 {
    local var_name "fake`i'"
    quietly psmatch2 `var_name' gdp_pc institutions inflation unemp pop_vote_share, kernel
    quietly reghdfe cos_multicult `var_name' leader [aweight=_weight], absorb(country_id year) cluster(election_id) nocons
    matrix rf_matrix[`i', 1] = _b[`var_name']
	matrix rf_matrix_ci_lower[`i', 1] = _b[`var_name'] - 1.96 * _se[`var_name']
	matrix rf_matrix_ci_upper[`i', 1] = _b[`var_name'] + 1.96 * _se[`var_name']
}

svmat double rf_matrix
svmat double rf_matrix_ci_lower
svmat double rf_matrix_ci_upper

twoway (kdensity rf_matrix1, bwidth(0.014) lcolor(gs8)), ///
	   scheme(s2mono) graphregion(color(white)) scale(1.8) ///
       xline(0, lpattern(dash) lcolor(gs8)) xlabel() ylabel(, angle(0) nogrid) ///
	   xtitle(" " "Coefficent value") ytitle("Density" " ") ///
	   legend(off)   
	   



 
 
 
 
 
 
 
 
 


